import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 客户档案-服务单元管理信息 */
export interface CustomerArchiveServiceUnit {
  id: number // id
  name: string // 服务单元名称
  belongDepart: string // 所属部门
  serviceType: string // 服务类型
  isTestUnit: string // 是否测试单元
  isReceiveMoney: string // 是否发起收款任务
  receiveMoneyType: string // 运维类合同收款负责人类型
  serviceArea: string // 服务区域
  address: string // 驻点地址
  lng: number // 经度
  lat: number // 纬度
  updateT: string | Dayjs // 修改时间
  ownerUserId: number // 负责人id
}

// 客户档案-服务单元管理 API
export const CustomerArchiveServiceUnitApi = {
  // 查询客户档案-服务单元管理分页
  getCustomerArchiveServiceUnitPage: async (params: any) => {
    return await request.get({ url: `/san/biz-customer-archive-service-unit/page`, params })
  },

  // 查询客户档案-服务单元管理详情
  getCustomerArchiveServiceUnit: async (id: number) => {
    return await request.get({ url: `/san/biz-customer-archive-service-unit/get?id=` + id })
  },

  // 新增客户档案-服务单元管理
  createCustomerArchiveServiceUnit: async (data: CustomerArchiveServiceUnit) => {
    return await request.post({ url: `/san/biz-customer-archive-service-unit/create`, data })
  },

  // 修改客户档案-服务单元管理
  updateCustomerArchiveServiceUnit: async (data: CustomerArchiveServiceUnit) => {
    return await request.put({ url: `/san/biz-customer-archive-service-unit/update`, data })
  },

  // 删除客户档案-服务单元管理
  deleteCustomerArchiveServiceUnit: async (id: number) => {
    return await request.delete({ url: `/san/biz-customer-archive-service-unit/delete?id=` + id })
  },

  /** 批量删除客户档案-服务单元管理 */
  deleteCustomerArchiveServiceUnitList: async (ids: number[]) => {
    return await request.delete({
      url: `/san/biz-customer-archive-service-unit/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出客户档案-服务单元管理 Excel
  exportCustomerArchiveServiceUnit: async (params) => {
    return await request.download({
      url: `/san/biz-customer-archive-service-unit/export-excel`,
      params
    })
  },

  // 简易服务单元管理列表
  getSimpleList: async (params: any) => {
    return await request.get({
      url: `/san/biz-customer-archive-service-unit/getSimpleList`,
      params
    })
  }
}
